package aad.storyboard.model;

import java.util.Observable;

import aad.storyboard.controller.GUIComposer;
import android.util.Log;

public class MoveAnimation extends Animation{
	
	private int xMove, yMove;
	private float xIntervalMovement;
	private float yIntervalMovement;
	
	public MoveAnimation(int xMove, int yMove, int duration,int time) {
		super(duration,time);
		this.xMove = xMove;
		this.yMove = yMove;
		this.currentDuration = 0;
		xIntervalMovement = (float) this.xMove/intervals;
		yIntervalMovement = (float) this.yMove/intervals;
	}

	public MoveAnimation(int xMove, int yMove, int duration) {
		super(duration);
		this.xMove = xMove;
		this.yMove = yMove;
		this.currentDuration = 0;
		xIntervalMovement = (float) this.xMove/intervals;
		yIntervalMovement = (float) this.yMove/intervals;
	}

	public void adjustParameters(){
			this.xMove = (int)-Math.ceil(this.currentDuration * xIntervalMovement);
			this.yMove = (int)-Math.ceil(this.currentDuration * yIntervalMovement);
	}


	@Override
	public void undo() {
		for(Image obj : this.images){
			obj.setPosX(obj.getPosX()+this.xMove);
			obj.setPosY(obj.getPosY()+this.yMove);
		}
		
	}

	@Override
	public void animate() {
		if(this.active){
			for(Image obj : this.images){
				//Log.e("asd","Moving from " + obj.getPosX()+" "+obj.getPosY()+", ix"+xIntervalMovement+" iy"+yIntervalMovement);
				obj.setPosX(obj.getPreciseX() + xIntervalMovement);
				obj.setPosY(obj.getPreciseY() + yIntervalMovement);
			}
		}
	}
	
	

}
